import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {


        ArrayList<Family> person = new ArrayList<>();

        Family per1 = new Family("父亲",66);
        Family per2 = new Family("母亲",64);
        Family per3 = new Family("小明",41);
        Family per4 = new Family("妻子",38);
        Family per5 = new Family("孩子1",10);
        Family per6 = new Family("孩子2",5);

        person.add(per1);
        person.add(per2);
        person.add(per3);
        person.add(per4);
        person.add(per5);
        person.add(per6);

        Family ageMax = person.get(0);
        Family ageMin = person.get(0);

        for (int i = 1; i < person.size(); i++) {

            Family f = person.get(i);
            int Max = ageMax.getAge();
            if(f.getAge()>Max){
                ageMax = f;
            }
            int min = ageMin.getAge();
            if(f.getAge()<min){
                ageMin = f;
            }
        }

        // 打印最大值最小值
        System.out.println("最小值:"+ageMin.getName()+" "+ageMin.getAge());
        System.out.println("最大值:"+ageMax.getName()+" "+ageMax.getAge());

        // 遍历集合
        person.forEach( per->System.out.println(per.getName()+" "+(per.getAge()+5)));




    }
}
